import http from '@/lib/http'

export interface CategoryPayload {
  id?: number
  name?: string
  description?: string
  icon?: string
  sortOrder?: number
}

export function fetchCategories(params?: any) {
  return http.get('/category', { params })
}

export function fetchCategoryList() {
  return http.get('/category/list')
}

export function fetchCategoryDetail(id: string | number) {
  return http.get(`/category/${id}`)
}

export function addCategory(data: CategoryPayload) {
  return http.post('/category', data)
}

export function updateCategory(data: CategoryPayload) {
  return http.put('/category', data)
}

export function deleteCategories(idList: (number|string)[]) {
  return http.delete('/category', { params: { idList } })
}
